public class Yunsuanfu {
        public static void main(String[] args) {
            // 基本布尔变量定义
            boolean a = true;
            boolean b = false;

            // 逻辑与（&）运算示例
            System.out.println("逻辑与（&）运算：");
            System.out.println("true & true = " + (a & a));
            System.out.println("true & false = " + (a & b));
            System.out.println("false & true = " + (b & a));
            System.out.println("false & false = " + (b & b));

            // 逻辑或（|）运算示例
            System.out.println("\n逻辑或（|）运算：");
            System.out.println("true | true = " + (a | a));
            System.out.println("true | false = " + (a | b));
            System.out.println("false | true = " + (b | a));
            System.out.println("false | false = " + (b | b));

            // 逻辑异或（^）运算示例
            System.out.println("\n逻辑异或（^）运算：");
            System.out.println("true ^ true = " + (a ^ a));
            System.out.println("true ^ false = " + (a ^ b));
            System.out.println("false ^ true = " + (b ^ a));
            System.out.println("false ^ false = " + (b ^ b));

            // 逻辑非（!）运算示例
            System.out.println("\n逻辑非（!）运算：");
            System.out.println("!true = " + (!a));
            System.out.println("!false = " + (!b));

            // 短路与（&&）运算示例（体现短路特性）
            int x = 10;
            System.out.println("\n短路与（&&）运算：");
            System.out.println("true && true = " + (a && a));
            System.out.println("true && false = " + (a && b));
            System.out.println("false && (x++ > 5) = " + (b && (x++ > 5)));
            System.out.println("短路与后x的值：" + x);

            // 短路或（||）运算示例（体现短路特性）
            int y = 20;
            System.out.println("\n短路或（||）运算：");
            System.out.println("true || true = " + (a || a));
            System.out.println("true || (y++ > 15) = " + (a || (y++ > 15)));
            System.out.println("false || true = " + (b || a));
            System.out.println("false || false = " + (b || b));
            System.out.println("短路或后y的值：" + y);
        }

}
